package com.qj.daibei.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.qj.daibei.mapper.DataFilingMapper;
import com.qj.daibei.pojo.DataFiling;
import com.qj.daibei.service.DataFilingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * author wml
 * Created on 2021/9/23 11:39
 */
@Service
public class DataFilingServiceImpl implements DataFilingService {

    @Autowired
    private DataFilingMapper dataFilingMapper;

    @Override
    public int saveDataFiling(DataFiling dataFiling) {
        return dataFilingMapper.insert(dataFiling);
    }

    @Override
    public DataFiling queryForRecordByUserId(Integer userId) {
        QueryWrapper<DataFiling> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id", userId);
        return this.dataFilingMapper.selectOne(queryWrapper);
    }

    @Override
    public int updateDataFiling(DataFiling dataFiling) {
        UpdateWrapper<DataFiling> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq("user_id", dataFiling.getUserId());
        return this.dataFilingMapper.update(dataFiling, updateWrapper);
    }
}
